/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package skelbkim;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

/**
 *
 * @author laimis  pratestuotas veikia..
 */
public class Skelbimai extends SeleneseTestCase {

    public void setUp() throws Exception {
        setUp("http://www.skelbimai.lt/", "*firefox");
    }

    public void newNotation(String noticeText, String phone, String name, String noticeTitle, String email) throws Exception {
        selenium.open("/skelbimo_ivedimas.php?nr=");
        if (isPageLoude()) {
            selenium.select("kid", "label=Paslaugos");
            selenium.click("//option[@value='5']");
            selenium.select("sid", "label=Web sprendimai");
            selenium.click("//option[@value='190']");
            selenium.select("apskritis", "label=Klaipėdos apskritis");
            selenium.click("//option[@value='-3']");
            selenium.select("sav", "label=Klaipėdos m. sav.");
            selenium.click("//option[@value='14']");
            selenium.type("pav", noticeTitle);
            selenium.type("tekstas", noticeText);
            selenium.type("vardas", name);
            selenium.type("telefonas", phone);
            selenium.type("email", email);
            selenium.click("susipazinau");
            selenium.click("new_skelb_submit");
        }
        selenium.stop();
    }

    private boolean isPageLoude() {
        boolean result = true;
        while (!selenium.isElementPresent("//*[@id='new_skelb_submit']")) {
            selenium.waitForPageToLoad("5000");
        }
        return result;
    }
}
